package estore.web_servlet;
import mybatis.dao.Mybatis;
import mybatis.yang.login_xinxi;

import java.io.IOException;

public class LoginServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
            String username=request.getParameter("username");
            String password=request.getParameter("password");
            System.out.println(username);
            System.out.println(password);
            request.getSession().setAttribute("username",username);
            Mybatis mybatis=new Mybatis();
            login_xinxi loginXinxi=new login_xinxi(username,password);
            try {
                boolean bol=mybatis.select(loginXinxi);
                if(bol==true){
                    System.out.println("Kkkk");
                    request.getRequestDispatcher("index.jsp").forward(request,response);
                }
                else {
                    request.getRequestDispatcher("loginworing.jsp").forward(request,response);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

    }
}
